﻿@model WebEntities.Models.Framework.WebsiteConfig

@{
    ViewBag.Title = "网站管理平台_网站参数配置";
}

@section HeadContent
{
    <script type="text/javascript">
        var savecfgSuccess = function (response, data) {
            Ext.Msg.show({ title: '提示', msg: data.extraParams.Msg, buttons: Ext.Msg.OK, icon: Ext.Msg.INFO, modal: true,
                fn: function (btn) {
                    App.BackgroundImageFile.setRawValue(data.extraParams.WebackPath);
                }
            });
        };

        var clearcfgSuccess = function (response, data) {
            console.log(data);
            Ext.Msg.show({ title: '提示', msg: data.extraParams.Msg, buttons: Ext.Msg.OK, icon: Ext.Msg.INFO, modal: true,
                fn: function (btn) {
                    App.BackgroundImageFile.setRawValue("");
                    App.BackgroundRepeat.setSelectedItems("none");
                }
            });
        };
    </script>
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().FormPanel()
            .ID("FormPanel1")
            .Layout("fit")
            .Items(
                Html.X().Panel()
                    .Border(false)
                    .Padding(5)
                    .Layout("form")
                    .Defaults(
                        Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                    )
                    .Items(
                        Html.X().HiddenFor(m => m.ArgID).ID("ArgID"),
                        Html.X().HiddenFor(m => m.BackgroundImage).ID("BackgroundImage"),
                        Html.X().FileUploadField().ID("BackgroundImageFile").FieldLabel("网站背景").Icon(Icon.ImageAdd).ButtonText("").Text(Model.BackgroundImage),
                        Html.X().ComboBoxFor(m => m.BackgroundRepeat).ID("BackgroundRepeat").FieldLabel("背景重复").Editable(false)
                            .Items(
                                Html.X().ListItem().Text("横向").Value("repeat-x"),
                                Html.X().ListItem().Text("纵向").Value("repeat-y"),
                                Html.X().ListItem().Text("横纵向").Value("repeat"),
                                Html.X().ListItem().Text("不重复").Value("no-repeat")
                            )
                    )
            )
            .TopBar(
                Html.X().Toolbar().Items(
                    Html.X().Button().Text("保存").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "SaveConfig";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在保存";
                            de.Click.Success = "savecfgSuccess";
                            de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                            de.Click.IsUpload = true;
                        })
                        .Listeners(ls =>
                        {
                            ls.Click.Handler = "return ext.net.comjs.onFormSubmit()";
                        }),
                    Html.X().Button().ID("BtnClear").Text("清除网页背景").Icon(Icon.Clipboard).DirectEvents(de =>
                        {
                            de.Click.Action = "ClearWebackground";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在清除背景";
                            de.Click.Success = "clearcfgSuccess";
                            de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                            de.Click.IsUpload = true;
                        })
                )
            )
            .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                    .Listeners(ls => ls.ValidityChange.Handler = "ext.net.comjs.setFormStatusBar(this, valid)")
    )
)